var app = getApp();
Page({
    data:{
        curPage : "/zofui_sales/fenxiao/aliaccount",
		siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
    },
    onLoad:function(options){
        var self = this;
        var zfid = options.zfid ? options.zfid : '';
        self.setData({
            options : options,
        });
        app.com.auth(function(user){
            app.com.http('fenxiao','POST',{zfid:zfid,op:'bill'},0,false,'','',function(res){
                if (!res.data.errno) {
                    self.setData({
                        Pagetheme : res.data.data.params.style,
                        userinfo : res.data.data.userinfo,
                        params : res.data.data.params,
                        sharedata : res.data.data.sharedata,
                        inited : true,
                    });
                    // 关闭下拉刷新
                    wx.stopPullDownRefresh();
                }else{
                    app.com.alert(res.data.message);
                }
            });
        });
        wx.setNavigationBarTitle({
          title:  '',
        });
       
    },
    formSubmit(){
        var self = this;
        var postdata = {
            op :'saveali',
            name : self.data.userinfo.aliname ? self.data.userinfo.aliname : '',
            aliaccount : self.data.userinfo.aliaccount ? self.data.userinfo.aliaccount : '',
            banktype : self.data.userinfo.banktype ? self.data.userinfo.banktype : '',
            bankname : self.data.userinfo.bankname ? self.data.userinfo.bankname : '',
            bankaccount : self.data.userinfo.bankaccount ? self.data.userinfo.bankaccount : '',
        };
        app.com.http('fenxiao','POST',postdata,0,true,'','',function(res){
            if( !res.data.errno && res.data ){
                var pages = getCurrentPages();
                var Page = pages[pages.length - 1];//当前页
                
                if(pages.length > 1){
                    var prePage = pages[pages.length - 2];
                    prePage.setData({
                        'userinfo.aliname' : postdata.name,
                        'userinfo.aliaccount' : postdata.aliaccount,
                    })
                }
            }
            app.com.alert(res.data.message);
        });
    },
    inputname(e){
        this.setData({
            'userinfo.aliname' : e.detail.value
        })
    },
    inputaccount(e){
        this.setData({
            'userinfo.aliaccount' : e.detail.value
        })
    },
    banktype(e){
        this.setData({
            'userinfo.banktype' : e.detail.value
        })
    },
    bankname(e){
        this.setData({
            'userinfo.bankname' : e.detail.value
        })
    },
    bankaccount(e){
        this.setData({
            'userinfo.bankaccount' : e.detail.value
        })
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },

})